//
//  MSTradeSuccessTableVC.m
//  SocietySale
//
//  Created by Mike on 16/11/15.
//  Copyright © 2016年 Mike. All rights reserved.
//

#import "MSTradeSuccessTableVC.h"
#import "MSTradeSuccessCell.h"

@interface MSTradeSuccessTableVC ()
//项目信息数据
@property(nonatomic,copy)NSArray *projectInfoArray;

@end

@implementation MSTradeSuccessTableVC


- (void)setModel:(MSTradeModel *)model{
    _model = model;
    NSString *tempStr = @"";
    if ([model.type isEqualToString:@"1"]) {//出售
        tempStr = @"出售";
    }
    else{//求购
        tempStr = @"求购";
    }
    NSString *type = [NSString stringWithFormat:@"%@%@",tempStr,model.projectType];

    if ([model.typeGroup isEqualToString:@"contacts"]){//联系人
        self.projectInfoArray = @[[DOKeyValue key:@"类型" value:type],
                                  [DOKeyValue key:@"项目" value:model.title],
                                  [DOKeyValue key:@"姓名" value:model.name],
                                  [DOKeyValue key:@"职务" value:model.position],
                                  ];
    }
    else{//项目进展
        self.projectInfoArray = @[[DOKeyValue key:@"类型" value:type],
                                  [DOKeyValue key:@"项目" value:model.title],
                                  [DOKeyValue key:@"主题" value:model.theme],
                                  [DOKeyValue key:@"内容" value:model.content],
                                  ];
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"InfoCell";
    MSTradeSuccessCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell==nil) {
        cell = [[MSTradeSuccessCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.data = self.projectInfoArray[indexPath.row];
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.projectInfoArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [MSTradeSuccessCell cellHeightWithModel:self.projectInfoArray[indexPath.row]];
}

@end
